package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class _034 {
    /**
     * 点赞
     */
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.valueOf(reader.readLine());
        int[] M = new int[1001];
        for (int i=0;i<N;i++){
            String[] s = reader.readLine().split(" ");
            for (int j =1;j<=Integer.valueOf(s[0]);j++){
                M[Integer.valueOf(s[j])]++;
            }
        }
        int max = Integer.MIN_VALUE;
        int temp=0;
        for (int i=1;i<M.length;i++){
            if (max<=M[i]){
                max= M[i];
                temp=i;
            }
        }
        System.out.println(temp+" "+max);
    }
}
